<?php

namespace App\Http\Controllers\Seller;

use App\Library\Mall\Shop\CatlogManagers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CatlogController extends BaseController
{
    use CatlogManagers;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->assign(['sideMenu'=>'catlog']);
    }

    public function index()
    {

        return $this->view('seller.catlog.index');
    }

    public function items()
    {
        $catid  = $this->request->input('catid');
        $catlog = $this->shop->catlogs()->find($catid);
        $items  = $catlog->items()->with('cates')->get();

        return $this->view('seller.catlog.items', compact('catlog', 'items', 'catid'));
    }

    public function cancel(Request $request)
    {
        $itemid = $request->input('itemid');
        $catid  = $request->input('catid');

        $this->shop->catlogs()->find($catid)->catlogItems()->where('itemid', $itemid)->delete();
        return ajaxReturn();
    }
}
